﻿@model Power
@Html.Extra()
@{
    Layout = "~/Views/Shared/OA/_Form.cshtml";
}
@section Toolbar
{
    @Html.MyNet().Button(new ButtonOptions { Text = "保存", Click = "save" })
    @Html.MyNet().Button(new ButtonOptions { Text = "返回", Click = "back" })
}
@section Main
{
    @Html.HiddenFor(model => model.Id)
    @Html.HiddenFor(model => model.HumanId)
    @Html.HiddenFor(model => model.HumanType)
    @Html.HiddenFor(model => model.PowerType)
    <table>
        <tr>
            <th>
                @Html.LabelFor(model => model.PowerKey, "表格")
            </th>
            <td>
                @Html.MyNet().TextBoxFor(model => model.PowerKey, new ValidateOptions
                {
                    RequiredError = "请输入表格",
                    LengthMax = 64
                })
                @Html.MyNet().ValidationMessageFor(model => model.PowerKey)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Operation, "操作")
            </th>
            <td>
                @Html.MyNet().DropDownListFor(model => model.Operation,
                new[]
                {
                    new { Value = TableOperation.All.ToString(), Name = TableOperation.All.ToText() },
                    new { Value = TableOperation.Read.ToString(), Name = TableOperation.Read.ToText() },
                    new { Value = TableOperation.Create.ToString(), Name = TableOperation.Create.ToText() },
                    new { Value = TableOperation.Modify.ToString(), Name = TableOperation.Modify.ToText() },
                }, "Value", "Name", "请选择操作",
                new ValidateOptions
                {
                    RequiredError = "请选择操作"
                })
                @Html.MyNet().ValidationMessageFor(model => model.Operation)
            </td>
        </tr>
        <tr>
            <th>
                @Html.LabelFor(model => model.Field, "字段")
            </th>
            <td>
                @Html.MyNet().TextAreaFor(model => model.Field, new ValidateOptions
                {
                    RequiredError = "请输入字段"
                })
                (*代表所有字段)
                @Html.MyNet().ValidationMessageFor(model => model.Field)
            </td>
        </tr>
    </table>
}
<script>

    function save()
    {
        var form = $("form");
        if (!form.valid()) return;

        $.ajax
        ({
            url: form.attr("action"),
            data: form.serialize(),
            type: "post",
            error: disposeError,
            success: function (result)
            {
                if (disposeException(result)) return;
                back(true);
            }
        });
    }
  
</script>
